import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/controller/schooladmin.dart';
import 'package:intl/intl.dart';

import '../../themes/appTheme.dart';

class SchoolReportsList extends StatelessWidget {
  final SchoolAdminController _schoolAdminController = Get.find();

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          margin: EdgeInsets.only(right: 12.0, bottom: 6.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                margin: EdgeInsets.only(right: 12.0),
                child: Text('School Reports'.tr,
                    style: TextStyle(
                      fontFamily: 'Montserrat',
                      color: Colors.white,
                      fontSize: 18.0,
                      letterSpacing: 1,
                    )),
              ),
              ElevatedButton(
                  style: ButtonStyle(
                      minimumSize:
                          MaterialStateProperty.all(Size(120.0, 30.0))),
                  child: Text(
                    'Check'.tr,
                    style: TextStyle(
                        fontFamily: 'Montserrat',
                        fontSize: 12.0,
                        color: Get.isDarkMode
                            ? Get.theme.primaryColorDark
                            : Get.theme.primaryColorLight),
                  ),
                  onPressed: () {
                    if (GetPlatform.isWeb) {
                      Get.toNamed('/schooladmin/reports');
                    } else {
                      Get.offAllNamed('/schooladmin/reports');
                    }
                  }),
            ],
          ),
        ),
        _schoolAdminController.obx(
          (data) {
            if (_schoolAdminController.schoolBasicStatics.value.result !=
                null) {
              return Container(
                margin: EdgeInsets.only(
                  right: 9.0,
                ),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    //////////BOOKS READ DATA BLOCK//////////
                    Expanded(
                      child: Container(
                        margin: EdgeInsets.only(right: 6.0),
                        padding: EdgeInsets.all(12.0),
                        decoration: BoxDecoration(
                          color: Get.isDarkMode
                              ? AppTheme.colors.darkTheme2
                              : Get.theme.primaryColorDark.withOpacity(0.1),
                          borderRadius: BorderRadius.circular(
                            6.0,
                          ),
                          boxShadow: [
                            BoxShadow(
                              blurRadius: 1,
                              spreadRadius: 1,
                              color: Get.isDarkMode
                                  ? Colors.transparent
                                  : Colors.black.withOpacity(0.1),
                              offset: Offset(1, 1),
                            ),
                          ],
                        ),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Container(
                              margin: EdgeInsets.only(bottom: 3.0),
                              padding: EdgeInsets.symmetric(
                                horizontal: 12.0,
                                vertical: 1.0,
                              ),
                              decoration: BoxDecoration(
                                  color: Get.isDarkMode
                                      ? Colors.black
                                      : Colors.black.withOpacity(0.1),
                                  borderRadius: BorderRadius.circular(9.0)),
                              child: Text(
                                "Books Read".tr,
                                style: TextStyle(
                                    fontFamily: 'Montserrat',
                                    fontSize: 14.0,
                                    color: Get.isDarkMode
                                        ? Get.theme.primaryColorDark
                                        : Get.theme.primaryColorLight),
                              ),
                            ),
                            Text(
                              NumberFormat.compact().format(
                                  _schoolAdminController.schoolBasicStatics
                                      .value.result!.readTimes),
                              style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 27.0,
                                color: Colors.white,
                              ),
                            )
                          ],
                        ),
                      ),
                    ),
                    //////////UNIQUE TITLE READ DATA BLOCK//////////
                    Expanded(
                      child: Container(
                        margin: EdgeInsets.only(right: 6.0),
                        padding: EdgeInsets.all(12.0),
                        decoration: BoxDecoration(
                          color: Get.isDarkMode
                              ? AppTheme.colors.darkTheme2
                              : Get.theme.primaryColorDark.withOpacity(0.1),
                          borderRadius: BorderRadius.circular(
                            6.0,
                          ),
                          boxShadow: [
                            BoxShadow(
                              blurRadius: 1,
                              spreadRadius: 1,
                              color: Get.isDarkMode
                                  ? Colors.transparent
                                  : Colors.black.withOpacity(0.1),
                              offset: Offset(1, 1),
                            ),
                          ],
                        ),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Container(
                              margin: EdgeInsets.only(bottom: 3.0),
                              padding: EdgeInsets.symmetric(
                                horizontal: 12.0,
                                vertical: 1.0,
                              ),
                              decoration: BoxDecoration(
                                  color: Get.isDarkMode
                                      ? Colors.black
                                      : Colors.black.withOpacity(0.1),
                                  borderRadius: BorderRadius.circular(9.0)),
                              child: Text(
                                "Titles Read".tr,
                                style: TextStyle(
                                  fontFamily: 'Montserrat',
                                  fontSize: 14.0,
                                  color: Get.isDarkMode
                                      ? Get.theme.primaryColorDark
                                      : Get.theme.primaryColorLight,
                                ),
                              ),
                            ),
                            Text(
                              NumberFormat.compact().format(
                                  _schoolAdminController.schoolBasicStatics
                                      .value.result!.readBooks),
                              style: TextStyle(
                                fontFamily: 'Montserrat',
                                color: Colors.white,
                                fontSize: 27.0,
                              ),
                            )
                          ],
                        ),
                      ),
                    ),
                    //////////QUIZZES TAKEN DATA BLOCK//////////
                    Expanded(
                      child: Container(
                        margin: EdgeInsets.only(right: 6.0),
                        padding: EdgeInsets.all(12.0),
                        decoration: BoxDecoration(
                          color: Get.isDarkMode
                              ? AppTheme.colors.darkTheme2
                              : Get.theme.primaryColorDark.withOpacity(0.1),
                          borderRadius: BorderRadius.circular(
                            6.0,
                          ),
                          boxShadow: [
                            BoxShadow(
                              blurRadius: 1,
                              spreadRadius: 1,
                              color: Get.isDarkMode
                                  ? Colors.transparent
                                  : Colors.black.withOpacity(0.1),
                              offset: Offset(1, 1),
                            ),
                          ],
                        ),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Container(
                              margin: EdgeInsets.only(bottom: 3.0),
                              padding: EdgeInsets.symmetric(
                                horizontal: 12.0,
                                vertical: 1.0,
                              ),
                              decoration: BoxDecoration(
                                  color: Get.isDarkMode
                                      ? Colors.black
                                      : Colors.black.withOpacity(0.1),
                                  borderRadius: BorderRadius.circular(9.0)),
                              child: Text(
                                "Quizzes Taken".tr,
                                maxLines: 1,
                                overflow: TextOverflow.fade,
                                style: TextStyle(
                                  fontFamily: 'Montserrat',
                                  fontSize: 14.0,
                                  color: Get.isDarkMode
                                      ? Get.theme.primaryColorDark
                                      : Get.theme.primaryColorLight,
                                ),
                              ),
                            ),
                            Text(
                              NumberFormat.compact().format(
                                  _schoolAdminController.schoolBasicStatics
                                      .value.result!.quizTimes),
                              style: TextStyle(
                                fontFamily: 'Montserrat',
                                fontSize: 27.0,
                                color: Colors.white,
                              ),
                            )
                          ],
                        ),
                      ),
                    ),
                  ],
                ),
              );
            } else {
              return Text("");
            }
          },
        ),
      ],
    );
  }
}
